#pragma once
#include "comm.hpp"
#include <set>


// 远程执行命令
class command
{
public:
    command(){}
    std::string Exexute(const std::string &cmd, InetAddr &addr)
    {
        FILE* fp = popen(cmd.c_str(), "r");
        if(fp == nullptr){
            std::cerr << "popen error" << std::endl;
            exit(POPEN_ERR);
        }
        std::string res;
        char buffer[128];
        while(fgets(buffer, sizeof(buffer), fp)){
            res += buffer;
        }
        return addr.InetToString() + "->" + res;
    }
    ~command(){}
};